<template>
	<view class="">
		<view class="profit">
			<view class="profit_top">
				<view class="name">累计收益</view>
				<view class="num">{{iconInfo.totalIncome}}</view>
			</view>
			<view class="right">参与{{iconInfo.day}}天</view>
		</view>
		<view class="profitTtime">

			<view class="left">
				<picker mode="date" fields="month" :end="newDay" @change="clickTab">
					<view :class=" 'profit_b active'">
						{{day}}
					</view>
				</picker>
				<image src="../../static/down.png" mode=""></image>
			</view>
			<view class="right">当月收益￥{{iconInfo.yesterIncome}}</view>
		</view>
		<view class="profitchart">
			<view class="">设备收益趋势</view>
			<view class="charts-box">
				<qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
			</view>
		</view>
		<view class="profitdetail">
			<view class="name">收益明细</view>
			<view class="tabname">
				<view class="">日期</view>
				<view class="">设备收益</view>
				<view class="">推广加成</view>
				<view class="">推广收益</view>
				<view class="">来源</view>
			</view>
			<scroll-view scroll-y="true" style="height: 500rpx;">
				<view class="list" v-for="(item,index) in iconInfo.list" :key="index"
					@click="jump(`./profitInfo?date=${item.date}&come_from=${item.come_from}`)">
					<view class="">{{item.date}}</view>
					<view class="col">+{{item.flow}}</view>
					<view class="col">+{{item.money}}</view>
					<view class="">
						{{item.point}}
					</view>
					<view class="">
						{{item.come_from_text}}
					</view>
					<image src="../../static/goin.png" mode=""></image>
				</view>
			</scroll-view>
		</view>
		<view style="height: 170upx;">

		</view>
		<TabBar :tabBarShow="3"></TabBar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0,
				chartData: {},
				opts: {
					color: ["#5990FF", "#00aa90", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 0], // 图位置
					enableScroll: false,
					xAxis: {
						disableGrid: true,
						labelCount: 14, //设置显示个数
						// format: 'formatterTime2'
						fontSize: '9',
						rotateLabel: true,
						marginTop: '5'
						// rotateAngle:'30'
					},
					fontSize: '10',
					dataLabel: false, // 数据显示
					legend: {
						show: false,
					},
					dataPointShape: false, // 圆点显示
					yAxis: {
						gridType: "dash",
						dashLength: 2,
					},
					extra: {
						area: {
							type: "curve",
							opacity: 0.8,
							addLine: true,
							width: 1,
							gradient: true,
							activeType: "hollow"
						}
					}
				},
				iconInfo: {
					totalIncome: 0,
					yesterIncome: 0,
					day: 0
				},
				lineData: [],
				day: '',
				newDay: ''
			};
		},
		watch: {
			lineData() {
				// this.xrDom()
			}
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '火虎智算',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '火虎智算',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		onLoad() {
			this.day = this.$fun.getYMD()
			this.newDay = this.$fun.getYMD()
			const phoneInfo = uni.getSystemInfoSync(); // 获取手机系统信息
			this.statusBarHeight = phoneInfo.statusBarHeight
		},
		onShow() {
			//模拟从服务器获取数据
			this.getServerData()
		},
		mounted() {
			// this.xrDom()
		},
		methods: {
			onUecharts() {
				let res = {
					categories: this.lineData ? this.lineData.date : [],
					series: [{
						name: "收益",
						data: this.lineData ? this.lineData.flow : 0
					}, ]
				};
				this.chartData = JSON.parse(JSON.stringify(res));
			},

			clickTab(e) {
				this.day = e.detail.value
				this.chartsDataLine1 = []
				this.getServerData()
			},
			jump(url) {
				this.$fun.jump(url)
			},
			getServerData() {
				let data = []
				this.$fun.ajax.post('butt/incomeList', {
					day: this.day
				}).then(res => {

					this.iconInfo = res.data
					// this.lineData = this.$fun.setArr(res.data.kline.date,res.data.kline.flow)
					this.lineData = res.data.kline
					console.log(this.lineData);
					this.onUecharts()
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #F5F1EE;
	}

	.profit {
		width: 690rpx;
		height: 158rpx;
		background: linear-gradient(180deg, #5990FF 0%, #55aaff 100%);
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		margin: 20rpx auto 0;
		position: relative;

		&_top {
			text-align: center;
			padding-top: 30rpx;
		}

		.name {
			font-weight: 500;
			font-size: 24rpx;
			color: #FFFFFF;
		}

		.num {
			font-weight: 500;
			font-size: 60rpx;
			color: #FFFFFF;
		}

		.right {
			font-weight: 500;
			font-size: 20rpx;
			width: 124rpx;
			height: 48rpx;
			line-height: 48rpx;
			text-align: center;
			background: #5990FF;
			border-radius: 0rpx 24rpx 0rpx 24rpx;
			color: #FFFFFF;
			position: absolute;
			right: 0;
			top: 0;
		}
	}

	.profitTtime {
		font-weight: 500;
		font-size: 32rpx;
		color: #333333;
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
		width: 750rpx;
		height: 88rpx;
		align-items: center;
		background: #FFFFFF;

		image {
			width: 28rpx;
			height: 28rpx;
		}

		.left {
			display: flex;
			align-items: center;
		}

		.right {
			font-weight: 400;
			font-size: 24rpx;
			color: #333333;
		}
	}

	.profitchart {
		width: 750rpx;
		height: 400rpx;
		background: #FFFFFF;
		font-weight: 600;
		font-size: 28rpx;
		color: #333333;
		padding: 30rpx 22rpx;

		.charts-box {
			width: 100%;
			height: 266rpx;
			// padding-right: 30rpx;
		}
	}

	.profitdetail {
		width: 690rpx;
		margin: 0 auto;

		.name {
			font-weight: 600;
			font-size: 28rpx;
			color: #333333;
			margin-top: 30rpx;
		}

		.tabname {
			font-weight: 500;
			font-size: 24rpx;
			color: #5990FF;
			display: flex;
			align-items: center;
			text-align: center;
			height: 60rpx;
			background: #00aaff10;
			padding: 0 20rpx 0 10rpx;
			margin-top: 20rpx;

			view {
				width: 25%;
			}
		}

		.list {
			width: 690rpx;
			height: 100rpx;
			background: #FFFFFF;
			font-weight: 400;
			font-size: 24rpx;
			color: #19181A;
			display: flex;
			align-items: center;
			text-align: center;

			.col {
				color: #5990FF;
			}

			view {
				width: 25%;
			}

			image {
				width: 28rpx;
				height: 28rpx;
				margin-right: 10rpx;
			}
		}
	}
</style>